#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
typedef double db;
inline int read()
{
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9') { if(ch=='-')f=-1; ch=getchar(); }
	while(ch>='0'&&ch<='9') { x=(x<<1)+(x<<3)+ch-'0'; ch=getchar(); }
	return x*f;
}
const int MAXN=5e4+10,MOD=10007;
int n,m,a[MAXN],sum[MAXN],f[2][MAXN],q[MAXN],l,r,ans1,ans2,cur;
bool check(int x)
{
	int cnt=0,tot=0;
	for(int i=1;i<=n;++i)
	{
		if(a[i]>x)return false;
		tot+=a[i];
		if(tot>x)
		{
			++cnt;
			tot=a[i];
		}
		if(cnt>m)return false;
	}
	return true;
}
int main()
{
	n=read();m=read();
	for(int i=1;i<=n;++i)a[i]=sum[i]=read(),sum[i]+=sum[i-1];
	l=1;r=sum[n];
	while(l<=r)
	{
		int mid=(l+r)>>1;
		if(check(mid))
		{
			ans1=mid;
			r=mid-1;
		}
		else l=mid+1;
	}
	printf("%d ",ans1);
	f[1][0]=1;
	for(int i=1;i<=m;++i)
	{
		q[l=r=1]=0;
		int tot=f[cur^1][0];
		for(int j=1;j<=n;++j)
		{
			while(l<=r&&sum[j]-sum[q[l]]>ans1)tot=(tot-f[cur^1][q[l++]]+MOD)%MOD;
			f[cur][j]=tot;
			tot=(tot+f[cur^1][q[++r]=j])%MOD;
		}
		for(int j=n-1;j;--j)
		{
			if(sum[n]-sum[j]>ans1)break;
			ans2=(ans2+f[cur][j])%MOD;
		}
		cur^=1;
		memset(f[cur],0,sizeof(f[cur]));
	}
	printf("%d\n",ans2);
	return 0;
}
